home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 001-025 / scopedisk14 / tcell / tcell.mod < prev    next >
Text File  |  1995-03-18  |  8KB  |  225 lines

  1. (*===========================================================================*)
  2. (*                             TCell                                         *)
  3. (*===========================================================================*)
  4. (*                                                                           *)
  5. (*              This is the main program                                     *) 
  6. (*                                                                           *)
  7. (*===========================================================================*)
  8. (*                                                                           *)
  9. (*              Original : Writen by David Siebert                           *)
  10. (*                         02-may-88                                         *)
  11. (*===========================================================================*)
  12. (*                                                                           *)
  13. (*             Modified  : 03-may-88 David Siebert                           *)
  14. (*                         looked for the bug                                *)
  15. (*                         05-may-88 David Siebert                           *)
  16. (*                         quite working on the program                      *)
  17. (*                         07-may-88 David Siebert                           *)
  18. (*                         looked at Virusx I don't like                     *)
  19. (*                         the way it worked no one but                      *)
  20. (*                         the DOS should write the                          *)
  21. (*                         Bootblock. There is a limit                       *)
  22. (*                         to what a program should do.                      *)
  23. (*                         01-jun-88 David Siebert                           *)
  24. (*                         Auto Checks Disk                                  *)
  25. (*                         04-jun-88 David Siebert                           *)
  26. (*                           Checks for Boot Bandit Virus                    *)
  27. (*===========================================================================*)
  28.  
  29. MODULE TCell;
  30. FROM MyStartupCode IMPORT StartUp,CloseUp;
  31. FROM SYSTEM IMPORT NULL,ADR,BYTE,ADDRESS;
  32. FROM Libraries IMPORT OpenLibrary,CloseLibrary;
  33. FROM Intuition IMPORT NewWindow,WindowPtr,Window,IDCMPFlagSet,WindowFlags,
  34. WindowFlagSet,ScreenFlags,ScreenFlagSet,IntuitionName,IntuitionBase,
  35. IntuiMessagePtr,IDCMPFlags,IntuitionText;
  36. FROM Ports IMPORT WaitPort,GetMsg,ReplyMsg,MessagePtr;
  37. FROM Strings IMPORT String;
  38. FROM Windows IMPORT OpenWindow,CloseWindow;
  39. FROM Text IMPORT ClearScreen;
  40. FROM NVK IMPORT Change,Di; 
  41. FROM VK IMPORT VCheck,TDD; 
  42. FROM Requesters IMPORT AutoRequest;
  43. FROM GraphicsLibrary IMPORT Jam1;
  44. FROM DOSCodeLoader IMPORT Execute;
  45. FROM DOSFiles IMPORT FileHandle,Open,Close,ModeNewFile,Write;
  46. FROM ASCII IMPORT CharIsPrintable;
  47.  
  48. (* $S-,$T-,$A+ *)
  49. VAR
  50.   MyData : TDD;
  51.   DriveName:ARRAY [0..3] OF String;
  52.   DriveString:ARRAY[0..3] OF String;
  53.   Qtemp:IDCMPFlagSet;
  54.   s1,
  55.   s2,
  56.   s3,
  57.   s4,
  58.   s5,
  59.   s6,
  60.   TITLE   :String;
  61.   Nwind   :NewWindow;
  62.   MyWindow:WindowPtr;
  63.   actt,
  64.   Act     :BOOLEAN;
  65.   MyClass :IDCMPFlagSet;
  66.   MyMsg   :IntuiMessagePtr;
  67.   TString1,
  68.   TString2,
  69.   TString3,
  70.   TString4:IntuitionText;
  71.   a,
  72.   Drive   :LONGCARD;
  73.   i       :INTEGER;
  74.   q       :FileHandle;
  75.   NC      :CHAR;
  76.   nq      :LONGINT;
  77.  
  78. PROCEDURE InForm(Drive:INTEGER);
  79. VAR 
  80.    i : INTEGER;
  81.  
  82. BEGIN
  83.    q:=FileHandle(NULL);
  84.    TString1.IText:=ADR(s4);
  85.    TString2.IText:=ADR(s5);
  86.    TString3.IText:=ADR(s6);
  87.    TString4.IText:=ADR(DriveString[Drive]);
  88.    IF AutoRequest(MyWindow,ADR(TString1),ADR(TString2),
  89.       ADR(TString3),Qtemp,Qtemp,250,65) THEN
  90.       q:=Open("CON:0/0/640/200/BootBlock",ModeNewFile);
  91.       FOR i:=1 TO 512 DO
  92.          IF CharIsPrintable(MyData[i]) THEN nq:=Write(q,ADR(MyData[i]),1);
  93.          ELSE
  94.             nq:=Write(q,ADR(NC),1);
  95.          END; 
  96.       END;(* END FOR *)
  97.    END; (* end if *)
  98.    TString1.IText:=ADR(s1);
  99.    TString2.IText:=ADR(s2);
  100.    TString3.IText:=ADR(s3);
  101.    Act:=AutoRequest(MyWindow,ADR(TString1),ADR(TString2),
  102.                     ADR(TString3),Qtemp,Qtemp,270,65);
  103.    Close(q);
  104.    IF Act THEN
  105.       q:=Open("NIL:",ModeNewFile); 
  106.       (* this is in my opinion is the way it initalize a bootblock *)
  107.       (* in a operating system friendly way. *)
  108.       IF Execute(DriveName[Drive],q,q) THEN
  109.       END; (* end if *)
  110.       Close(q);
  111.    END; (*end if*)
  112. END InForm;
  113.  
  114. BEGIN
  115. (* initalize a lot of data that is one thing that c does a lot better *)
  116.   StartUp;
  117.   NC:=".";
  118.   DriveName[0]:="c:Install DF0:";
  119.   DriveName[1]:="c:Install DF1:";
  120.   DriveName[2]:="c:Install DF2:";
  121.   DriveName[3]:="c:Install DF3:";
  122.   DriveString[0]:=" On Drive DF0:";
  123.   DriveString[1]:=" On Drive DF1:";
  124.   DriveString[2]:=" On Drive DF2:";
  125.   DriveString[3]:=" On Drive DF3:";
  126.   Qtemp:=IDCMPFlagSet{};
  127.   TITLE:="TCell";
  128.   s1:=" Non Stanadard Boot Block";
  129.   s2:=" INSTALL";
  130.   s3:=" DON'T INSTALL";
  131.   s4:=" Show Boot Block ?";
  132.   s5:=" Show";
  133.   s6:=" DontShow";
  134.   WITH TString1 DO
  135.      FrontPen := BYTE(0);
  136.      BackPen  := BYTE(1);
  137.      DrawMode :=BYTE(Jam1);
  138.      LeftEdge :=3;
  139.      TopEdge  :=5;
  140.      ITextFont :=NULL;
  141.      NextText :=ADR(TString4);
  142.   END; (* TString1 *)
  143. WITH TString2 DO
  144.      FrontPen := BYTE(0);
  145.      BackPen  := BYTE(1);
  146.      DrawMode :=BYTE(Jam1);
  147.      LeftEdge :=3;
  148.      TopEdge  :=3;
  149.      ITextFont :=NULL;
  150.      NextText :=NULL;
  151.   END; (* TString2 *)
  152.   WITH TString3 DO
  153.      FrontPen := BYTE(0);
  154.      BackPen  := BYTE(1);
  155.      DrawMode :=BYTE(Jam1);
  156.      LeftEdge :=3;
  157.      TopEdge  :=3;
  158.      ITextFont :=NULL;
  159.      NextText :=NULL;
  160.   END; (* TString3 *)
  161.   WITH TString4 DO
  162.      FrontPen := BYTE(0);
  163.      BackPen  := BYTE(1);
  164.      DrawMode :=BYTE(Jam1);
  165.      LeftEdge :=3;
  166.      TopEdge  :=14;
  167.      ITextFont :=NULL;
  168.      NextText :=NULL;
  169.   END; (* TString4 *)
  170.   WITH Nwind DO
  171.      LeftEdge  :=0;
  172.      TopEdge   :=0;
  173.      Width     :=128;
  174.      Height    :=10;
  175.      DetailPen :=BYTE(0);
  176.      BlockPen  :=BYTE(1);
  177.      IDCMPFlags :=IDCMPFlagSet{DiskInserted,CloseWindowFlag};
  178.      Flags     :=WindowFlagSet{WindowDepth,GimmeZeroZero,WBenchWindow,
  179.       WindowDrag,WindowClose,Borderless};
  180.      FirstGadget :=NULL;
  181.      CheckMark :=NULL;
  182.      Title :=ADR(TITLE);
  183.      Screen :=NULL;
  184.      BitMap :=NULL;
  185.      MinWidth:=20;
  186.      MinHeight :=20;
  187.      MaxWidth:=600;
  188.      MaxHeight :=200;
  189.      Type:=ScreenFlagSet{WBenchScreen};     
  190.   END; (*With*)
  191. (* here is the real program *)
  192.   FOR Drive:=0 TO 3 DO
  193.      IF Di[i].IsHere THEN
  194.         IF VCheck(Drive,MyData) THEN
  195.         (* set up the auto requester *)
  196.            InForm(INTEGER(Drive));         
  197.         END; (* end if *)
  198.      END; (* end if *)
  199.   END; (* end for *)
  200.   MyClass:=IDCMPFlagSet{};
  201.   MyWindow:=OpenWindow(Nwind);
  202.   IF MyWindow <> NULL THEN
  203.     REPEAT
  204.        MyMsg:=ADDRESS(WaitPort(MyWindow^.UserPort));
  205.        MyMsg:=ADDRESS(GetMsg(MyWindow^.UserPort));
  206.        MyClass:=MyMsg^.Class;
  207.        ReplyMsg(ADDRESS(MyMsg));
  208.        IF (MyClass = IDCMPFlagSet{DiskInserted}) THEN
  209.            (* the code in the module that the procdure Change is from is *)
  210.            (* some of the worst I have written. and would not have been even*)
  211.            (* been nessasary if Intuition had done the smart thing and *)
  212.            (* returned the drive number of the drive that had been changed*)
  213.            (* in the code field *)
  214.             Drive:=Change();
  215.            IF VCheck(Drive,MyData) THEN
  216.              (* set up the auto requester *)
  217.               InForm(INTEGER(Drive));         
  218.            END; (* end if *)
  219.        END; (* end if *)
  220.     UNTIL (MyClass = IDCMPFlagSet{CloseWindowFlag});
  221.     CloseWindow(MyWindow);
  222.  END; (*IF *)
  223. CloseUp;
  224. END TCell.
  225.